package com.steven.treatment_nurse.adapter;

import android.graphics.Color;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.steven.treatment_nurse.R;
import com.steven.treatment_nurse.entity.CallState;
import com.steven.treatment_nurse.entity.HSBedEntity;

import java.util.List;

public class HSBedRecycleAdapter extends BaseQuickAdapter<HSBedEntity, BaseViewHolder> implements CallState {
    private List<HSBedEntity> hsList;

    public HSBedRecycleAdapter(List<HSBedEntity> hsBedEntities) {
        super(R.layout.item_hs_bed, hsBedEntities);
        this.hsList = hsBedEntities;
    }


    @Override
    protected void convert(BaseViewHolder helper, HSBedEntity item) {
        RelativeLayout relCall = helper.getView(R.id.rel_call);//呼叫

        switch (item.getCallState()) {
            case Normal://正常状态
                relCall.setVisibility(View.GONE);
                break;
            case Called://被呼叫
                relCall.setVisibility(View.VISIBLE);
                relCall.setBackgroundResource(R.drawable.call_red);
                break;
            case Calling://通话中
                relCall.setVisibility(View.VISIBLE);
                relCall.setBackgroundResource(R.drawable.call_green);
                break;
        }

        TextView tv_title = helper.getView(R.id.tv_title);//床位
        TextView tv_name = helper.getView(R.id.tv_name);//姓名
        TextView tv_sex = helper.getView(R.id.tv_sex);//性别
        TextView tv_age = helper.getView(R.id.tv_age);//年龄
        TextView tv_birth = helper.getView(R.id.tv_birth);//出生日期
        TextView tv_admissionTime = helper.getView(R.id.tv_admissionTime);//入院时间
        TextView tv_case = helper.getView(R.id.tv_case);//病例
        tv_title.setText(item.getHsBed());
        if (item.getName()!=null&&!item.getName().equals("")){
            tv_name.setText(item.getName());
            tv_sex.setText(item.getSex());
            tv_age.setText(item.getAge());
//        tv_birth.setText(item.getBirthDate());
            tv_admissionTime.setText(item.getAdmissionTime());
            tv_case.setText(item.getCaseHS());
            tv_name.setTextColor(Color.parseColor("#000000"));
        }else {
            tv_name.setText("空床位");
            tv_name.setTextColor(Color.parseColor("#999999"));
        }
    }

}
